import httpx


def raise_for_status_with_details(response: httpx.Response):
    """
    Raises an HTTPStatusError with additional response body info
    if the response status is not 2xx.
    """
    try:
        response.raise_for_status()
    except httpx.HTTPStatusError as e:
        try:
            error_detail = response.json()
        except Exception:
            error_detail = response.text or str(e)

        raise RuntimeError(error_detail) from e
